package controller

import (
	"fmt"
	"github.com/gin-gonic/gin"
	"gocode.com/m/model"
	"strconv"
)

func GetProject(context *gin.Context) {
	projectId := context.Param("id")
	fmt.Println(projectId)
	// projectId转换成int类型
	projectIdInt, err := strconv.Atoi(projectId)
	fmt.Println("转换后id", projectIdInt)
	if err != nil {
		context.JSON(400,
			gin.H{
				"message": "projectId转换失败",
			})
		return
	}
	project, err := model.GetProjectByID(projectIdInt)
	context.JSON(200,
		gin.H{
			"message": "success",
			"data":    project,
		})
	return
}
